package com.flyweight.flyweight;

public class TestFlyWeight {
    public static void main(String[] args) {
        WebSiteFactory factory = new WebSiteFactory();
        WebSite xinwen = factory.getWebSite("新闻");
        xinwen.use(new User("客户1"));

        WebSite boke = factory.getWebSite("博客");
        boke.use(new User("客户2"));

        WebSite xinwen2 = factory.getWebSite("新闻");
        xinwen2.use(new User("客户3"));

        WebSite xinwen3 = factory.getWebSite("新闻");
        xinwen3.use(new User("客户4"));

        //可以看到池子里面只有两个对象
        System.out.println("-------- 池中的web对象个数： "+factory.getCount()+"--------");
        System.out.println("xinwen == xinwen2 == xinwen3   ????? ");
        System.out.println(xinwen == xinwen2);
        System.out.println(xinwen3 == xinwen2);
    }
}
